import collections


class Solution(object):
    def numEquivDominoPairs(self, dominoes):
        """
        :type dominoes: List[List[int]]
        :rtype: int
        """
        dominoes = [(num[0], num[1]) if num[0] <= num[1] else (num[1], num[0]) for num in dominoes]
        d = collections.Counter(dominoes)
        return sum([d[key] * (d[key] - 1) // 2 for key in d])


data = Solution()
dominoes = [[1, 2], [2, 1], [3, 4], [5, 6]]
print(data.numEquivDominoPairs(dominoes))
